<!DOCTYPE HTML>
<html>
<head th:include="/common/head :: head">
</head>
<body class="pos-r">
<div >
	<nav class="breadcrumb" th:include="/common/navbar :: navbar('活动管理中心','活动管理首页')"></nav>
	<div class="page-container">
		<div class="col-sm-12">
			<form id="mainForm" action="/activity/list" method="post">
			<div class="col-sm-4" th:include="/common/datebetween :: datebetweennolimit('报名时间','registrationStartTime',${entity.registrationStartTime},'registrationEndTime',${entity.registrationEndTime})"></div>
			<div class="col-sm-4" th:include="/common/datebetween :: datebetweennolimit('活动时间','activityStartDate',${entity.activityStartDate},'activityEndDate',${entity.activityEndDate})"></div>
			<div class="col-sm-4">
				<input class="btn btn-primary radius" type="submit" value="搜索" />
				<input class="btn btn-primary radius" type="button" onclick="doFormReset('mainForm')" value="重置" />
			</div>
			</form>
		</div>
		
		<div class="cl pd-5 bg-1 bk-gray mt-20 col-sm-12"> 
			<span class="l">
				<a class="btn btn-primary radius" th:onclick="'javascript:show(\'发布活动\',\'/activity/add\');'"  href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 发布活动</a>
			</span> 
			<span class="r">查询结果：共有  <strong th:text="${ #lists.size(list)}">54</strong> 条记录</span> 
		</div>
		
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="40">活动标题</th>
						<th width="100">报名时间</th>
						<th width="100">活动时间</th>
						<th width="40">发布情况</th>
						<th width="40">报名人数</th>
						<th width="40">通过人数</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr class="text-c va-m" th:each="vo,voStat : ${list}">
						<td class="text-l" >
							<a style="color:blue" th:onclick="'javascript:toShow(\'活动详情\',\'/activity/view\',\''+${vo.id}+'\');'"  href="javascript:;"><span th:text="${vo.name}" ></span></a>
						</td>
						<td class="text-l" th:text="${vo.registrationStartTime+'--'+vo.registrationEndTime}"></td>
						<td class="text-l" th:text="${#calendars.format(vo.activityStartDate,'yyyy-MM-dd HH:mm:ss')+'--'+#calendars.format(vo.activityEndDate,'yyyy-MM-dd HH:mm:ss')}"></td>
						<td class="td-status"><span class="label label-success radius" th:text="${vo.publishStatus.value}">已发布</span></td>
						<td class="text-l">
							<a style="color:blue" th:onclick="'javascript:show(\'活动报名审批\',\'/activity/user/list?activityId='+${vo.id}+'\',\'\');'"  href="javascript:;"><span th:text="${vo.enrollmentNum}" ></span></a>
						</td>
						<td class="text-l">
							<a style="color:blue" th:onclick="'javascript:show(\'活动报名审批\',\'/activity/user/list?activityId='+${vo.id}+'\',\'\');'"  href="javascript:;"><span th:text="${vo.adoptNum}" ></span></a>
						</td>
						<td class="td-manage">
							<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'活动详情\',\'/activity/view\',\''+${vo.id}+'\');'" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe725;</i></a> 
							<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'修改活动\',\'/activity/update\',\''+${vo.id}+'\');'" href="javascript:;" title="修改"><i class="Hui-iconfont">&#xe6df;</i></a> 
							<a th:if="${vo.publishStatus.value == '未发布' }" style="text-decoration:none" class="ml-5" th:onclick="'javascript:del(\''+${vo.id}+'\');'" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

		
//初始化表格
$('.table-sort').dataTable({
	"aaSorting" : [ [ 1, "desc" ] ],//默认第几个排序
	"bStateSave" : true,//状态保存
	"aoColumnDefs" : [ {
		"orderable" : false,
		"aTargets" : [ 6 ]
	} // 制定列不参与排序
	]
});

/*产品-添加*/
function product_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*产品-查看*/
function product_show(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*产品-审核*/
function product_shenhe(obj,id){
	layer.confirm('审核文章？', {
		btn: ['通过','不通过'], 
		shade: false
	},
	function(){
		$(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="product_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
		$(obj).remove();
		layer.msg('已发布', {icon:6,time:1000});
	},
	function(){
		$(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="product_shenqing(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
		$(obj).remove();
    	layer.msg('未通过', {icon:5,time:1000});
	});	
}
/*产品-下架*/
function product_stop(obj,id){
	layer.confirm('确认要下架吗？',function(index){
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="product_start(this,id)" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
		$(obj).remove();
		layer.msg('已下架!',{icon: 5,time:1000});
	});
}

/*产品-发布*/
function product_start(obj,id){
	layer.confirm('确认要发布吗？',function(index){
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="product_stop(this,id)" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
		$(obj).remove();
		layer.msg('已发布!',{icon: 6,time:1000});
	});
}

/*产品-申请上线*/
function product_shenqing(obj,id){
	$(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
	$(obj).parents("tr").find(".td-manage").html("");
	layer.msg('已提交申请，耐心等待审核!', {icon: 1,time:2000});
}

/*产品-编辑*/
function product_edit(title,url,id){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}

/*产品-删除*/
function product_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

function del(id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/activity/delete?id='+id,
			dataType: 'text',
			success: function(data){
				if(data){
					layer.msg('删除成功!',{icon:1,time:1000},function(){
						window.parent.location.reload();
					});
				}else{
					layer.msg('删除失败!'+data,{icon:2,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script>
</body>
</html>